home *** CD-ROM | disk | FTP | other *** search
- static char rcsid[] = "$Id: getkey.c,v 1.2 1992/11/10 20:02:34 mike Exp $";
-
- /* $Log: getkey.c,v $
- * Revision 1.2 1992/11/10 20:02:34 mike
- * - Changed `getkey' for the Atari GEM version.
- *
- * Revision 1.1 1992/09/14 13:02:14 mike
- * Initial revision
- *
- */
-
- /* getkey.c : get a keycode from the <key device>
- * C Durland
- */
-
- /* Copyright 1990, 1991 Craig Durland
- * Distributed under the terms of the GNU General Public License.
- * Distributed "as is", without warranties of any kind, but comments,
- * suggestions and bug reports are welcome.
- */
-
- #include <const.h>
- #include <char.h>
- #include "ed.h"
- #include "../me2/stio.h"
-
- KeyCode Eprefixes[] = { META, PFIX1, PFIX2, PFIX3 };
-
- /* Ectok(kc,part2) : character to keycode
- * kc : keycode to convert
- * part2: TRUE if kc might be part2 of prefixed ME key
- * (eg in "ESC a" => ctok(a,TRUE) because second part of prefixed
- * keys are always uppercase. "SOFKEY a" => ktoc(a,FALSE) because
- * softkeys get the whole keymap. Prefix keys are listed in table
- * above.)
- */
- KeyCode Ectok(kc,part2) register KeyCode kc; register int part2;
- {
- if ((kc & 0xFF00) == 0) /* Only munge it if its not already a KeyCode */
- {
- if (part2) kc = toupper(kc); /* Force to uppercase */
- if (iscntrl(kc)) kc = CTRL | (kc ^ 0x40); /* control a -> C-A */
- }
- return kc;
- }
-
- /* Read in a key.
- * Do the standard keyboard preprocessing.
- * Convert the keys to the internal character set.
- */
- KeyCode Eget_key(pkeys,key)
- PKey *pkeys;
- int key; /* Value from evnt_keybd call or 0. */
- {
- register KeyCode kc;
- register int j;
-
- Cursor_on();
- kc = Ectok(t_getcharX(key),FALSE);
- Cursor_off();
- for (j = PKEYS; j--; ) /* check for prefix keys */
- if (kc == pkeys[j]) return Eprefixes[j] | Ectok(t_getcharX(0),TRUE);
- return kc;
- }
-